package br.ufal.tci.nexos.arcolive.service.conference.command;

import br.ufal.tci.nexos.arcolive.ArCoLIVEServerProperties;
import br.ufal.tci.nexos.arcolive.ArCoLIVEServiceInstance;
import br.ufal.tci.nexos.arcolive.ArCoLIVEServiceManager;
import br.ufal.tci.nexos.arcolive.command.ArCoLIVEClientCommand;
import br.ufal.tci.nexos.arcolive.command.ArCoLIVECommandResult;
import br.ufal.tci.nexos.arcolive.service.connection.ConnectionRequest;

public class GetStreamVideoURLCommand extends ArCoLIVEClientCommand {
    
	public GetStreamVideoURLCommand(ConnectionRequest request) {
		super(request);
	}
	
	public ArCoLIVECommandResult executeImpl() {
		int serviceId = this.request.getProtocolId();
		int instanceId = this.request.getIntegerParameter("instanceId").intValue();
		
		String response = "1";
		
		ArCoLIVEServiceManager serviceManager = ArCoLIVEServiceManager.getInstance();
		ArCoLIVEServiceInstance serviceInstance = serviceManager.getServiceInstance(serviceId, instanceId);
		int startPort = serviceInstance.getIntAttribute("startPort");
		
		response += "#ip=" + ArCoLIVEServerProperties.getInstance().getStringProperty("server.ip") + "#port=" + startPort;
	
		return new ArCoLIVECommandResult(this, response);
	}

}